<?php 
// this file and function checked admin session value stored or not
require_once '../model/testimonials.php';
require_once '../model/users.php';
require_once '../includes/classes/pagination_class.php';	

// create object
$testimonialObj = new Model_Testimonial();
$user           = new Model_Users(); 

// GET VARIABLES WITH SORT , PAGE ,ORDER BY   VARIABLE   WHICH ARE 
	// HIDDEN VARIABLES
   
	//$page = $_GET['page'];
	$id   = base64_decode($_GET['id']); 
	$user_id = base64_decode($_GET['uid']); 
	
// if all values are correct while updating or editing the testimonial	
if(isset($_POST['addtestimonial_btn']) &&  $_POST['username']!=''  && $_POST['description']!=''){
	
	$addTestimonial                = array();
	$addTestimonial['user_id']     = $_POST['username'];
/*	$addTestimonial['title']       = strtolower($_POST['title']);*/
	$addTestimonial['description'] = html_entity_decode($_POST['description']);
	$addTestimonial['status']      = '1';
	$addTestimonial['added_date']  = date("Y-m-d H:m:s");	
	$testimonialObj->add_Testimonial($addTestimonial);
	$_SESSION['msg']="<div class='success_msg'><span>Testimonial added successfully!</span></div>";
	header('location:'.SITE_URL.'/admin/home.php?q=testimonials');
	exit;
}
	
// getting all registered user names from database to show in selection box  Here user_type=4.
	$userDetails = $user->getAllActiveUsers($search, $limit='',$offset='');
	$smarty->assign("userArray",$userDetails); 

	

	## Set active class variable for left menu  (main menu and sub menu)
$smarty->assign('activeclass', 'testimonial');
$smarty->assign('mainmenu', '3');

$smarty->display(TEMPLATEDIR_ADMIN . 'testimonials/testimonial_add.tpl');
unset($smarty);

?>